<template>
<div>
  <el-row>
    <el-col :span="12"><div class="grid-content bg-purple">
      <el-menu
          router

          default-active="2"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose">
        <el-menu-item :index="o.url" v-for="(o,index) in menuData" :key="o.id"
                      :route="{ path: o.url, query: { id: o.id } }">
          <i class="el-icon-menu"></i>
          <span slot="title" >{{o.name}}</span>
        </el-menu-item>
<!--        <el-menu-item index="tianpin">
          <i class="el-icon-menu"></i>
          <span slot="title">甜品</span>
        </el-menu-item>
        <el-menu-item index="zaocan">
          <i class="el-icon-menu"></i>
          <span slot="title">早餐</span>
        </el-menu-item>-->
      </el-menu>
    </div>
    </el-col>
    <el-col :span="12"><div class="grid-content bg-purple-light">
      <router-view/>
    </div></el-col>
  </el-row>
</div>
</template>

<script>
export default {
  name: "CaiPinView",
  data(){
    return {
      menuData: []
    };
  },
  methods: {

    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    initMenuCate(){
      this.axios.get("http://localhost:8084/food/cateList").then(resp=>{
        this.menuData=resp.data;
      })
    }
  },
  created() {
    this.initMenuCate()
  }
}
</script>

<style scoped>
.el-row {
  margin-bottom: 20px;
&:last-child {
   margin-bottom: 0;
 }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>